package com.activiti.advance;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * 在创建流程实例阶段，进行关联 BusinessKey
 * BusinessKey 关联
 *
 * @author ldanniel
 */
public class ActivitiBusinessKeyRelation {
    public static void main(String[] args) {
        //创建
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //获取流程实例处理的service - RuntimeService
        RuntimeService runtimeService = processEngine.getRuntimeService();
        //根据流程定义的id启动流程
        String businessKey = "10001";
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myEvection",businessKey);
        //输出内容
        //输出内容
        System.out.println("流程定义Id" + processInstance.getProcessDefinitionId());
        System.out.println("流程实例Id" + processInstance.getId());
        System.out.println("当前活动的Id" + processInstance.getActivityId());
        System.out.println("出差申请单的id:[BusinessKey] =" + processInstance.getBusinessKey());
    }
}
